package com.yunji.storage.service.impl;

import com.yunji.common.utils.bean.BeanUtils;
import com.yunji.storage.bo.AllocateListQueryBO;
import com.yunji.storage.bo.AllocateRemoveBO;
import com.yunji.storage.bo.AllocateSelectQueryBO;
import com.yunji.storage.context.AllocateTicketConvert;
import com.yunji.storage.dao.IAllocateTicketDao;
import com.yunji.storage.domain.AllocateTicketDO;
import com.yunji.storage.service.IAllocateTicketService;
import com.yunji.storage.vo.AllocateTicketVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @Project: yunji-coffee
 * @Package: com.yunji.storage.service.impl
 * @Title: AllocateTicketServiceImpl
 * <p>
 * History:
 * Date                     Version     Author          Summary
 * ============================================================
 * 2024-08-20 15:06:25      V1.0        HuaAo       新建类
 */
@Service
public class AllocateTicketServiceImpl implements IAllocateTicketService {

    @Resource
    IAllocateTicketDao allocateTicketDao;

    @Override
    public List<AllocateTicketVO> searchVOList(AllocateListQueryBO bo) {
        List<AllocateTicketDO> list = allocateTicketDao.search(bo);
        if (BeanUtils.isNull(list)) {
            return new ArrayList<>();
        }

        return AllocateTicketConvert.domainToVO(list);
    }

    @Override
    public boolean create(AllocateTicketDO allocateTicket) {
        return allocateTicketDao.create(allocateTicket);
    }

    @Override
    public boolean update(AllocateTicketDO allocateTicket) {
        return allocateTicketDao.updateTicket(allocateTicket);
    }

    @Override
    public AllocateTicketDO select(Long allocateId) {
        return allocateTicketDao.getById(allocateId);
    }

    @Override
    public AllocateTicketDO select(AllocateSelectQueryBO bo) {
        return allocateTicketDao.select(bo);
    }

    @Override
    public boolean deleteDraft(Long... allocateIds) {
        return allocateTicketDao.deleteDraft(allocateIds);
    }

    @Override
    public boolean deleteByTicket(AllocateRemoveBO bo) {
        return allocateTicketDao.deleteByTicket(bo);
    }

}